﻿using AdminFrame.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;

namespace AdminFrame.Permissions;

public class AdminFramePermissionDefinitionProvider : PermissionDefinitionProvider
{
    public override void Define(IPermissionDefinitionContext context)
    {
        // 系统管理组
        var sysManagementGroup = context.AddGroup(AdminFramePermissions.SysManagement, L("SysManagement"));

        // 添加系统管理访问权限
        sysManagementGroup.AddPermission(AdminFramePermissions.SysManagementAccess, L("SysManagement"));

        // 参数管理
        var parameters = sysManagementGroup.AddPermission(AdminFramePermissions.Parameters, L("Parameters"));
        parameters.AddChild(AdminFramePermissions.ParametersCreate, L("Create"));
        parameters.AddChild(AdminFramePermissions.ParametersEdit, L("Edit"));
        parameters.AddChild(AdminFramePermissions.ParametersDelete, L("Delete"));
        parameters.AddChild(AdminFramePermissions.ParametersView, L("View"));
    }

    private static LocalizableString L(string name)
    {
        return LocalizableString.Create<AdminFrameResource>(name);
    }
}
